#include <dlfcn.h>
#include <iostream>

int (*functionA)(int input);

int main()
{
  void* handle;
  char* error;
  handle=dlopen("libsub.so",RTLD_LAZY);
  if(!handle)
  {
    std::cerr<<"Open Shared Lib Error "<<dlerror()<<std::endl;
    return 0;
  }
  //这里GCC会进行符号修饰
  functionA=(int(*)(int))dlsym(handle,"_Z8functioni");
  if((error=dlerror())!=nullptr)
  {
    std::cout<<"Load Function Error "<<error<<std::endl;
    return 0;
  }
  std::cout<<"Call Function Result "<<(*functionA)(100)<<std::endl;
  dlclose(handle);
  return 0;
}
